<html>
<head>
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<link rel="stylesheet" href="styles/staff.css" type="text/css" />
<script type="text/javascript">
function checkall(class_name, obj) {
		//Duyệt qua các checkbox có class = class_name (item)
		//Trả về các phần tử ở dạng mảng, bắt dầu từ vị trí 0;
		var items = document.getElementsByClassName(class_name);
		if(obj.checked == true) //Đã được chọn
		{
			for(i=0; i < items.length ; i++)
				items[i].checked = true;
		}
		else { //Checkbox chưa được chọn
			for(i=0; i < items.length ; i++)
				items[i].checked = false;
		}
	}
</script>
</head>
<body>
<?php
if(isset($_SESSION["appro-error"])){
    echo($_SESSION["appro-error"]);
    unset($_SESSION["appro-error"]);
}
require("model/connect.php");

$baitren_mottrang = 10;
$studentid = $_GET['studentid'];
$classid = $_GET['classid'];
if ( !isset($_GET['page']) )
{
    $page = 0 ;

}else
{
    $page= $_GET['page'];
}
$sodu_lieu = mysql_num_rows(mysql_query("Select cr.registrtion_ID,cr.Student_ID, cr.course_ID, c.Course_Name from CourseRegistration cr inner join Course  c on cr.Course_ID=c.Course_ID where cr.STUDENT_ID='".$studentid."' and cr.Approved='notyet'") ) or die(mysql_error());

$sotrang = $sodu_lieu/$baitren_mottrang;

$result =mysql_query("Select cr.registrtion_ID,cr.Student_ID, cr.course_ID, c.Course_Name from CourseRegistration cr inner join Course  c on cr.Course_ID=c.Course_ID where cr.STUDENT_ID='".$studentid."' and cr.Approved='notyet' LIMIT ".$page*$baitren_mottrang.",".$baitren_mottrang) or die(mysql_error());
?>
<table class="gridtable">
<form action="control/faculty-proc-approve-reg.php" method="POST">
<tr>
	<th>Mã đăng ký</th><th>Mã số sinh viên</th><th>Mã môn học</th><th>Tên môn học</th><th><input type="checkbox" onclick="checkall('item', this)" name="check" class="checkbox" />Check All</th>
</tr>
<?php
while ( $info = mysql_fetch_array($result )) 
{
    ?>
<tr>
	<td><?php echo $info[0].""  ?></td><td><?php echo $info[1].""  ?></td><td><?php echo $info[2].""  ?></td><td><?php echo $info[3].""  ?></td><td><?php echo "<input type=\"checkbox\" class=\"item\"  name=\"id[]\" class=\"checkbox\" value=\"{$info[0]}\"/> "  ?>Chấp nhận</td>
</tr>
    <?php
}
?>
<input type="hidden" name="classid" value="<? echo "".$classid ?>"/>
<input type="hidden" name="studentid" value="<? echo "".$studentid ?>"/>
<input type="submit" value="Chấp nhận"/>
</form>
</table>
<?php
for ( $page = 0; $page < $sotrang; $page ++ )
{
echo "<a href='faculty-index.php?p=faculty-list-course-appro&studentid={$studentid}&classid={$classid}&page={$page}'>{$page} </a>";
} 

mysql_close();
?>
</body>
</html>

